<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@page import="com.opensymphony.xwork2.ActionContext"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="s" uri="/struts-tags" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/fare/js/show.js"></script>--%>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/lib/ligerUI/js/ligerui.min.js"></script>
 <link href="<%=request.getContextPath() %>/fare/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" /> 
<link href="<%=request.getContextPath()%>/fare/js/ligerUI/skins/Gray/css/all.css" rel="stylesheet"
	type="text/css" />
<link href='<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css' rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/common.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/multiblepicker.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/FDCDialog.js"></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/ajaxfileupload.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/citylist.js'></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/FDCDialog.js"></script>
<link rev="stylesheet" media="all" href="<%=request.getContextPath() %>/fare/css/form_style.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<%=request.getContextPath()%>/jsFile/fdc.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath() %>/jsFile/wait/js/wait.js"></script>	
<!-- 圆角文本框 -->
<link href="<%=request.getContextPath() %>/fare/css/htc/htc.css" rel="stylesheet" type="text/css" />
<%-- <style>
#mybutton{
	border:1px solid #ccc;
	background:#fff;
	color:#000;
	padding:5px 15px;
}
</style> --%>

<script type="text/javascript">
$(function ()
 {
	$.ajax({
        url : 'parseAction!getSource.action',
        cache : false, 
        async : false,
        type : "POST",
       	complete: function(jqXHR, textStatus){
       		if(jqXHR.status==200){
       			result = parseObj(jqXHR.responseText);
       			var data = result;
       			
       			loadGrid(data);
       			
       		}else{
       			alert('查询失败,请与管理员联系');
       		}
       	}
    });
           
        });
        
function loadGrid(data){
	var grid=$("#maingrid").ligerGrid({
			dataAction:'local',
	        enabledSort:true,    // 就否允许排序
	        data:data,
			dataType:"local",
			columns: [
		                { display: '', width: 30, isAllowHide: false, name: 'checkbox', isSort: false,
		                    render: function (row)
		                    {
		                        var html = '<input type ="checkbox" rowid ="' + row.id + '" style="text-align: center;">';
		                        return html;
		                    },
		                    headerRender: function (column)
		                    {
		                        var html = '<input type ="checkbox" onclick="selectAll(this)">';
		                        return html;
		                    }
		                }, { 
		                	display: '航空公司', name: 'companyName', width: 200},
		                 {
		                	display:"代号",name:'carrierKey',width:100
		                 }, {
		                    display: '操作', isAllowHide: false,width: 400,
		                    render: function (row)
		                    {  
		                        var html =  '<a href="javascript:void(0);" onclick="onedit(\'' + row.carrierKey + '\')">自动解析 \|</a>' +		
		                                    '<input type="file" id="uploadFile'+row.carrierKey+'"name="uploadFile'+row.carrierKey+'" onchange="javascript:upload(\'' + row.carrierKey + '\');" style="display:none"/>'+
		                                    '<a href="javascript:void(0);" onclick="uploadFile'+row.carrierKey+'.click()" id="mybutton">手动解析</a>'; 
		                    
		                       		  
		                        /*  '<a href="javascript:void(0);" onclick=""> | 手动解析</a>'; */
		                        return html;
		                    }
		                }                 
		                ],width:'100%',
		                	height:'100%' ,
		                pageSizeOptions: [5, 10, 15, 20] 
		});
	
}
        function selectAll(obj)
        {
            $("#maingrid td[columnname=checkbox]").find(":checkbox").each(function ()
            {
                this.checked = obj.checked; 
            });
        }
        function onedit(key)
        {
        	var url;
        	
        	switch(key){
        	    case 'CA':url='';break;
        		case 'CZ':url='parseAction!autoParse.action';break;
        		case 'MF':url='parseAction!autoParse.action';break;
        		case 'MU':url='parseAction!autoParse.action';break;
        		case 'SC':url='';break;
        		case '3C':url='';break;
        		case 'HU':url='parseAction!autoParse.action';break;
        		case 'ZH':url='parseAction!autoParse.action';break;
        		default:;
        	}
            if(url!=''){
            	<%-- FDCDialog.lockWindow(true,'<%=request.getContextPath() %>'); --%>
            	FDCWait.show();
            	$.ajax({
            		   type: "POST",
            		   url: url,
            		   data:"carrierKey="+key,
            		   dataType:"text",
            		
            		   success: function(msg){
            			   if(msg=='OK'){
            				   alert("解析成功!");
                			   FDCWait.hide();
            			   }
            			   
            		   }
            		});
            }else{
            	alert("功能还在建设中...");
            }
        	
        	
        }
        function upload(key){
        	var url;
        	//alert(key);
        	switch(key){
        	    case 'CA':url='guoHangParseAction!pdfParse.action';break;
        		case 'CZ':url='';break;
        		case 'MF':url='';break;
        		case 'MU':url='';break;
        		case 'SC':url='shanHangParseAction!pdfParse.action';break;
        		case '3C':url='chuanHangParseAction!pdfParse.action';break;
        		case 'HU':url='haiHangParseAction!pdfParse.action';break;
        		case 'ZH':url='shenHangParseAction!pdfParse.action';break;
        		default:;
        	}
            if(url!=''){
            	
            	var flag=confirm("确认上传？");
            	if(!flag){
            		return false;
            	}
                $("#loading")
                .ajaxStart(function(){
                	FDCDialog.lockWindow(true,'<%=request.getContextPath() %>');
                })//开始上传文件时显示一个图片
                .ajaxComplete(function(){
                   // $(this).hide();
                });//文件上传完成将图片隐藏起来
                $.ajaxFileUpload
                (
                    {
                        url:url,//用于文件上传的服务器端请求地址
                        secureuri:false,//一般设置为false
                        fileElementId:'uploadFile'+key,//文件上传空间的id属性  <input type="file" id="file" name="file" />
                        dataType: 'json',//返回值类型 一般设置为json/text
                        success: function (data, status)  //服务器成功响应处理函数
                        {   
                        	alert(data.result);
                        	FDCDialog.unLockWindow();
                        },
                        error: function (data, status, e)//服务器响应失败处理函数
                        {
                            alert(e);
                        }
                    }
                )
                
                return false;
            	
            	
            	/* $.ajax({
            		   type: "POST",
            		   url: url,
            		   dataType:"text",
            		  /*  async: false, */
            		  /* success: function(msg){
            		     alert(msg);
            		   }
            		}); */
            }else{
            	alert("功能还在建设中...");
            }
        	
        }
        function showalert(content)
        {
            $.ligerMessageBox.alert('提示内容', content);
        }
        function getSelectedIds()
        {
            var rowids = "";
            $("#maingrid .l-grid-row td[columnindex=0]").find(":checkbox").each(function ()
            {
                if (this.checked)
                    rowids += $(this).attr("rowid") + ",";
            });
            if (rowids.length > 0) rowids = rowids.substr(0, rowids.length - 1);
            alert(rowids);
        }
        function getSelected()
        {
            var manager = $("#maingrid").ligerGetGridManager();
            var row = manager.getSelectedRow();
            alert("您选择的是:" + row.name + " | " + row.birthday);
        }
</script>

</head>

<body>

	<div class="form_table_tltle" >查询条件 </div>
	<img src="<%=request.getContextPath()%>/images/um/ajaxLoader.gif" id="loading" style="display: none;">	
	 <div id="maingrid"></div>
</body>
</html>

